package com.softhinker.ke24.unit3.model;

import java.io.Serializable;

public class Stock implements Serializable, Comparable<Stock> {
	
	private static final long serialVersionUID = -3849870767498454700L;
	private String counterName;
	private String code;
	private String background;
	private int votes = 0;
	
	public Stock(String code){
		this.code = code;
	}
	
	public String getBackground() {
		return background;
	}

	public void setBackground(String background) {
		this.background = background;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getCounterName() {
		return counterName;
	}

	public void setCounterName(String counterName) {
		this.counterName = counterName;
	}

	public double getScore() {
		double score = (double)getVotes() / 3;
		return score;
	}

	public String toString(){
		return this.getCounterName();
	}

	public int getVotes() {
		return votes;
	}

	public void setVotes(int votes) {
		this.votes = votes;
	}

	@Override
	public int compareTo(Stock o) {
		if(this.getScore() > o.getScore()){
			return -1;
		} else if(this.getScore() < o.getScore()){
			return 1;
		} else{
			return 0;
		}
	}
}
